{{extend 'layout.html'}}

<h1>{{=page.title}}</h1>

{{ if is_admin: }}
{{=button(T('smartedit'),'showEditable',page.url)}}
{{=button(T('move page'),'movePage',page.id)}}
{{pass}}

{{for i in range(0,len(page_items)):}}
	{{if page_items[i].tablename=="page_text":}}
		<div class="pageText">
		{{if content[i].title:}} 
			{{=H2(content[i].title)}}
		{{pass}}
		{{if content[i].type=="html":}}
			{{=XML(content[i].body)}}
		{{elif content[i].type=="markmin":}}
			{{=MARKMIN(content[i].body, extra={'space':lambda code: '<br>'})}}
		{{else:}}
			{{=content[i].body}}
		{{pass}}
		</div>
	{{elif page_items[i].tablename=="page_image":}}
		{{if content[i].hasLightbox:}}
		<a href="{{=URL('download',args=content[i].image)}}" rel="pageImage" title="{{=content[i].title}}">
		{{pass}}
		  <img class="pageImage" src="{{=URL('download',args=content[i].image)}}" alt="{{=content[i].title}}" />
		{{if content[i].hasLightbox:}}
		</a>
		{{pass}}
	{{elif page_items[i].tablename=="page_file":}}
		<div class="pageLink">
			<a href="{{=URL('download',args=content[i].file)}}" class="subLink">
			<div class="pageIcon">
				{{=pageIcon(content[i].file)}}
			</div>
			<div class="pageInfo">
				{{=content[i].title}}
			</div>
			</a>
			<div style="clear:both;"></div>
		</div>
	{{elif page_items[i].tablename=="page_link":}}
		<div class="pageLink">
			<a href="{{=content[i].link}}" target="_blank" class="subLink">
			<div class="pageIcon">
				{{=pageIcon(content[i].link)}}
			</div>
			<div class="pageInfo">
				{{=content[i].title}}
			</div>
			</a>
			<div style="clear:both;"></div>
		</div>
	{{elif page_items[i].tablename=="page_faq":}}
		<div class="pageFAQ">
			<div class="pageFAQQuestion">
				{{=B(content[i].question)}}
			</div>
			<div class="pageFAQAnswer">
				{{=content[i].answer}}
			</div>
			<div style="clear:both;"></div>
		</div>
	{{elif page_items[i].tablename=="page_picasa":}}
		{{photos=content[i]}}
		<div class="pagePicasa">
			{{if len(photos) > 6:}}
			<div id="picPrev"></div>
			<div id="picNext"></div>
			{{pass}}
			{{for x in range(0,len(photos)):}}
				{{if x > 5:}}
					{{if (x+1) % 6 == 0:}}
						<img id="{{=x}}" class="googlepicasa" src="{{=photos[x].media.thumbnail[0].url.replace('s72','s110-c')}}" title="{{=photos[x].media.thumbnail[0].url.replace('s72','s680')}}" border="0" style="display:none;"/>
					{{else:}}
						<img id="{{=x}}" class="googlepicasa" src="{{=photos[x].media.thumbnail[0].url.replace('s72','s110-c')}}" title="{{=photos[x].media.thumbnail[0].url.replace('s72','s680')}}" border="0" style="display:none;"/>
					{{pass}}
				{{else:}}
					{{if x == 5:}}
						<img id="{{=x}}" class="googlepicasa" src="{{=photos[x].media.thumbnail[0].url.replace('s72','s110-c')}}" title="{{=photos[x].media.thumbnail[0].url.replace('s72','s680')}}" border="0" style="display:inline; border:0;"/>
					{{else:}}
						<img id="{{=x}}" class="googlepicasa" src="{{=photos[x].media.thumbnail[0].url.replace('s72','s110-c')}}" title="{{=photos[x].media.thumbnail[0].url.replace('s72','s680')}}" border="0" style="display:inline;"/>
					{{pass}}
				{{pass}}
			{{pass}}
			<div style="clear:both;"></div>
		</div>
		<a href="{{=photos[0].media.thumbnail[0].url.replace('s72','s2000')}}" rel="googlePicasa" class="picLink"><img id="picHeader" border="0" src="{{=photos[0].media.thumbnail[0].url.replace('s72','s680')}}"></a>
		<div style="clear:both;"></div>
		<script type="text/javascript">
		$(document).ready(function() {
		  	$("a[rel=googlePicasa]").fancybox({
		  		'transitionIn'  :   'elastic',
		  	    'transitionOut' :   'elastic'
		  	});
		});
		
		$(".googlepicasa").click(function(){
		  var thisHref = $(this).attr("title");
		  var thisRel = thisHref.replace('s680','s2000');
		  $("#picHeader").attr("src",thisHref);
		  $(".picLink").attr("href",thisRel);
		});
		
		$("#picPrev").click(function(){
		    var neededArray = [];
		    $(".googlepicasa").each(function (index, domEle) {
		        if($(this).css('display') != 'none') {
		        	maxID=index;
		            var neededID = (index - 6);
		            if(neededID >= 0) {
		                neededArray.push(index);
		            }
		        }
		    });
		    $.each(neededArray, function(index, value) { 
		        neededID = (value - 6);
		        $(".googlepicasa").eq(value).css('display', 'none');
		        $(".googlepicasa").eq(neededID).css('display', 'inline');
		        if(neededID==0) {
		        	$(".googlepicasa").eq(5).css('border-right', '0');
		        }
		        if(neededID == (maxID - 6) && neededID > 5) {
		        	$(".googlepicasa").eq(neededID).css('border-right', '0');
		        }
		    });
		});
		
		$("#picNext").click(function(){
		    var maxID = $(".googlepicasa").length;
		    var neededArray = [];
		    $(".googlepicasa").each(function (index, domEle) {
		        if($(this).css('display') != 'none') {
		            var neededID = (index + 6);
		            if(neededID < maxID) {
		                neededArray.push(index);
		            }
		        }
		    });
		    $.each(neededArray, function(index, value) { 
		        neededID = (value + 6);
		        $(".googlepicasa").css('border-right', '4px solid #FFF');
		        $(".googlepicasa").eq(value).css('display', 'none');
		        $(".googlepicasa").eq(neededID).css('display', 'inline');
		        if((neededID + 1) % 6 == 0 || (neededID + 1) == maxID) {
		        	$(".googlepicasa").eq(neededID).css('border-right', '0');
		        }
		    });
		});
		</script>
	{{elif page_items[i].tablename=="page_youtube":}}
		<div class="pageYoutube"><iframe width="640" height="480" src="http://www.youtube.com/embed/{{=content[i].youtube}}?rel=0" frameborder="0" allowfullscreen></iframe></div>
	{{elif page_items[i].tablename=="page_slider":}}
        <div class="slider-wrapper theme-default">
            <div id="slider_{{=content[i].id}}" class="nivoSlider" style="width: {{=content[i].width}}px; height: {{=content[i].height}}px;">
			{{for x in ('image1','image2', 'image3', 'image4', 'image5', 'image6', 'image7', 'image8', 'image9', 'image10'):}}
				{{if content[i][x]:}}
				<img src="{{=URL('static','temp', args=content[i][x])}}" alt="" />
                {{pass}}
            {{pass}}
            </div>
        </div>
        <div style="clear:both;">&nbsp;</div>
    <script type="text/javascript" src="{{=URL('static','js/nivoslider/jquery.nivo.slider.js')}}"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider_{{=content[i].id}}').nivoSlider();
    });
    </script>
	{{pass}}
{{pass}}

{{if (page_children and page.showChildren):}}
<div class="pageSubmenu">
{{if page.childrenTitle:}}{{=H2(page.childrenTitle)}}
{{else:}}{{=SPAN(H2(T('Sub pages')))}}{{pass}}
	<div style="height:112px;">
		{{for page in page_children:}}
		<a href="{{=URL('page', 'show/%s' % page.url)}}" title="{{=page.title}}" class="subLink">
			{{if page.imageThumb:}}<div class="subBlock" style="background-image: url('{{=URL(r=request,c='static',f='images/thumbs/' + page.imageThumb)}}');"></div>
			{{elif page.image:}}<div class="subBlock" style="background-image: url('{{=URL('download',args=page.image)}}');"></div>
			{{else:}}<div class="subBlock"><div class="subBlock-text">{{=page.title}}</div></div>{{pass}}
		</a>
		{{pass}}
		<div style="clear:both;"></div>
	</div>
</div>
<div style="clear:both;"></div>
{{pass}}

<script type="text/javascript">
$(document).ready(function() {
    $("a[rel=iframe]").fancybox({
        'type': 'iframe',
        'width': 600,
        'height': 450,
        'scrolling': 'auto',
        'autoDimensions': true,
        'showNavArrows': false,
        'hideOnOverlayClick': true,
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'overlayColor' :    '#FFFFFF'
    });
	$(".subBlock").mouseout(function(){
  	  	$(this).css("border","1px solid #e0e0e2");
  	  	$(this).css("width","116px");
  		$(this).css("height","87px");
  	  	$(this).css("margin","9px");
  	  	$(this).css("background-size","116px");
  	  	$(this).find('.subBlock-text').css("padding", "32px 0 0 0");
	  	$(this).css("-moz-border-radius", "15px");
	  	$(this).css("-webkit-border-radius", "15px");
	  	$(this).css("border-radius", "15px");
  	});
  	$(".subBlock").mouseover(function(){
  		$(this).css("margin","0");
  		$(this).css("border","4px solid #e0e0e2");
  		$(this).css("height","99px");
  		$(this).css("width","128px");
  		$(this).css("background-size","128px");
  		$(this).find('.subBlock-text').css("padding", "38px 6px 0 6px");
	  	$(this).css("-moz-border-radius", "22px");
	  	$(this).css("-webkit-border-radius", "22px");
	  	$(this).css("border-radius", "22px");
  	});
});
</script>
<div style="clear:both;"></div>